package com.hpsk.shopgen.model.genconfig.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hpsk.shopgen.model.genconfig.entity.GenConfig;
import com.hpsk.shopgen.model.genconfig.dao.GenConfigMapper;
import com.hpsk.shopgen.model.genconfig.param.GenConfigListParam;
import com.hpsk.shopgen.model.genconfig.service.IGenConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 生成配置 服务实现类
 * </p>
 *
 * @author huangwang
 * @since 2025-07-07
 */
@Service
public class GenConfigServiceImpl extends ServiceImpl<GenConfigMapper, GenConfig> implements IGenConfigService {

    @Override
    public List<GenConfig> list(GenConfigListParam genConfigListParam) {
        QueryWrapper<GenConfig> wrapper = getQueryWrapper(genConfigListParam);
        return this.list(wrapper);
    }

    private static QueryWrapper<GenConfig> getQueryWrapper(GenConfigListParam genConfigListParam, QueryWrapper<GenConfig> wrapper) {
        if (wrapper == null) {
            wrapper = new QueryWrapper<>();
        }
        wrapper.eq(ObjectUtil.isNotEmpty(genConfigListParam.getBasicId()), "basic_id", genConfigListParam.getBasicId());
        return wrapper;
    }
    private static QueryWrapper<GenConfig> getQueryWrapper(GenConfigListParam genConfigListParam) {
        return getQueryWrapper(genConfigListParam, new QueryWrapper<>());
    }
}
